package basics.day18.ArrayList.forEachDemo;

import basics.day18.ArrayList.ArrayLIstReview.Person;

import java.util.ArrayList;
import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        // fun_1();
        // fun_2();
        fun_3();
    }

    public static void fun_3() {
        ArrayList<Person> arrayList = new ArrayList<Person>();
        arrayList.add(new Person("张三1",121));
        arrayList.add(new Person("张三2",122));
        arrayList.add(new Person("张三3",123));
        arrayList.add(new Person("张三4",124));
        for (Person p :
                arrayList) {
            System.out.println(p);
        }
    }

    public static void fun_2() {
        String[] str = {"张三", "李四"};
        for (String s :
                str) {
            System.out.println(s);
        }
    }

    public static void fun_1() {
        /* *
         * for增强遍历，i就是数组里面的变量
         */
        int[] ints = {1, 2, 3, 4, 5};
        for (int i :
                ints) {
            i = i + 1;
            System.out.println(i);
        }
        System.out.println("==============");
        String s = Arrays.toString(ints);
        System.out.println(s);
    }
}
